package com.bestvike.stone.spring.concurrent;

import java.util.concurrent.TimeUnit;

/**
 * 可重入分布式锁
 * Created by 许崇雷 on 2018/5/31.
 */
public interface IDistributedLock<TLockObject extends LockObject> {
    /**
     * 申请锁
     *
     * @param name      资源名称
     * @param waitTime  等待时间
     * @param leaseTime 持有时间
     * @param unit      时间单位
     * @return 成功返回锁对象, 否则抛出异常
     */
    TLockObject acquire(String name, long waitTime, long leaseTime, TimeUnit unit) throws LockFailedException;

    /**
     * 续订锁
     *
     * @param lockObject 锁对象
     */
    void renewal(TLockObject lockObject);

    /**
     * 释放锁
     *
     * @param lockObject 锁对象
     */
    void release(TLockObject lockObject);
}
